package com.aidex.web.controller.api;

import com.aidex.biz.domain.*;
import com.aidex.biz.domain.bo.WeiRongBackBo;
import com.aidex.biz.service.*;
import com.aidex.biz.smy.dto.BaseDTO;
import com.aidex.biz.smy.service.HitService;
import com.aidex.biz.smy.vo.BaseVO;
import com.aidex.biz.utils.*;
import com.aidex.biz.utils.hengchang.HengChangServer;
import com.aidex.common.annotation.Log;
import com.aidex.common.core.controller.BaseController;
import com.aidex.common.enums.BusinessType;
import com.aidex.common.utils.StringUtils;
import com.aidex.common.utils.http.HttpUtils;
import com.aidex.common.utils.sign.Md5Utils;
import com.aidex.framework.cache.ConfigUtils;
import com.aidex.web.controller.tool.Base64Util;
import com.aidex.web.controller.tool.XunSuBangAesUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.*;

/**
 * 客户信息推送
 *
 * @author sean
 * @email 2074844820@qq.com
 * @date 2022-04-22
 */
@RestController("ApiPushCustomerController")
@RequestMapping("/webApi/pushCustomer")
public class PushCustomerController extends BaseController {
    private static final String Ning_Bo_URL = "http://crm.cyrcar.com/api/webApi/pushCustomer";
    @Autowired
    private CustomerService customerService;
    @Autowired
    private HitService hitService;
    @Autowired
    private RxkOrderService rxkOrderService;
    @Autowired
    private HengChangServer hengChangServer;
    @Autowired
    private ZifangPushService zifangPushService;
    @Autowired
    private MessageInfoService messageInfoService;

    /**
     * 恒昌回传
     *
     * @param params
     * @return
     */

    @RequestMapping(value = "/synCustomerInfoCallBack", method = RequestMethod.POST)
    @ResponseBody
    public Map synCustomerInfoCallBack(@RequestBody JSONObject params) {
        String channelNum = params.getString("channelNum");
        String requestData = params.getString("requestData");
        JSONObject jsonObject = hengChangServer.synCustomerInfoCallBack(channelNum, requestData);
        String channelOrderNum = jsonObject.getString("channelOrderNum");
        ZifangPush zifangPush = zifangPushService.get(channelOrderNum);
        if (zifangPush != null) {
            zifangPush.setStatus(jsonObject.getString("codeMsg"));
            String code = jsonObject.getString("code");
            switch (code) {
                case "F001":
                    zifangPush.setAmount(jsonObject.getString("loanAmount"));
                    break;
                case "S001":
                    zifangPush.setAmount(jsonObject.getString("creditAmount"));
                    break;
                case "Q001":
                    zifangPush.setAmount(jsonObject.getString("signAmount"));
                    break;
            }
            zifangPushService.save(zifangPush);
            jsonObject.put("desc", "成功");
            jsonObject.put("code", 200);
        } else {
            jsonObject.put("desc", "订单不存在");
            jsonObject.put("code", 500);
        }
        return jsonObject;
    }

    /**
     * /**
     * 已接通 1
     *
     * @param customer
     * @return
     */
    @Log(title = "左心房客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertZxf", method = RequestMethod.POST)
    @ResponseBody
    public Map insertZxf(@RequestBody Customer customer) {
        customer.setLaiyuan("左心房");
        String[] area = customer.getCityName().split("-");
        if (area.length == 2) {
            customer.setCityName(area[1]);
        }
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 2 周三对接
     *
     * @param customer
     * @return
     */
    @Log(title = "欧乐客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertOuLe", method = RequestMethod.POST)
    @ResponseBody
    public Map insertOuLe(@RequestBody Customer customer) {
        customer.setLaiyuan("欧乐");
        String name = customer.getCusName();
        customer.setCusName(name.replaceAll("左心房", "").replaceAll("（", "").replaceAll("）", ""));
        return customerService.savePushCustomer(customer);
    }

    /**
     * 接通
     *
     * @param customer
     * @return
     */
    @Log(title = "惠利客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertHuiLi", method = RequestMethod.POST)
    @ResponseBody
    public Map insertHuiLi(@RequestBody Customer customer) {
        customer.setLaiyuan("惠利");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 大鹅客户推送信息(撞库)
     *
     * @param param
     * @return
     */
    @Log(title = "大鹅客户推送信息(撞库)", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/check", method = RequestMethod.POST)
    @ResponseBody
    public BaseVO hitUser(@RequestBody BaseDTO param) {
        BaseVO baseVO = hitService.handlerHit(param);
        return baseVO;
    }

    /**
     * 已接通 4
     *
     * @param param
     * @return
     */
    @Log(title = "大鹅客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/infoSubmit", method = RequestMethod.POST)
    @ResponseBody
    public BaseVO infoSubmit(@RequestBody BaseDTO param) {
        BaseVO baseVO = hitService.handlerCommit(param);
        return baseVO;
    }

    /**
     * 已接通 5
     *
     * @param customer
     * @return
     */
    @Log(title = "巨匠客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJujiang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJujiang(@RequestBody Customer customer) {
        customer.setLaiyuan("巨匠");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 6
     *
     * @param jsonObject
     * @return
     */
    @Log(title = "客哆客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertKeDuo", method = RequestMethod.POST)
    @ResponseBody
    public Map insertKeDuo(@RequestBody JSONObject jsonObject) {
        Customer customer = new Customer();
        customer.setLaiyuan("客哆");
        customer.setCusName(jsonObject.getString("customer_name"));
        customer.setPhone(jsonObject.getString("customer_phone"));
        customer.setSex(jsonObject.getString("customer_sex"));
        customer.setCityName(jsonObject.getString("customer_region"));
        customer.setAmount(jsonObject.getString("loan_money"));
        customer.setRemark(jsonObject.getString("media") + "/" + jsonObject.getString("loan_type"));
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通
     *
     * @param jsonObject
     * @return
     */
    @Log(title = "聚网客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJuWang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJuWang(@RequestBody JSONObject jsonObject) {
        Customer customer = new Customer();
        customer.setLaiyuan("聚网");
        customer.setCusName(jsonObject.getString("cname"));
        customer.setPhone(jsonObject.getString("tel"));
        String sex = "未知";
        if (null != jsonObject.getInteger("sex")) {
            if (jsonObject.getInteger("sex") == 1) {
                sex = "女";
            }
            if (jsonObject.getInteger("sex") == 2) {
                sex = "男";
            }
        }
        customer.setSex(sex);
        customer.setCityName(jsonObject.getString("city"));
        customer.setAmount(jsonObject.getString("xqed"));
        String laiyuan = jsonObject.getString("fromId");
        if ("124".equals(laiyuan)) {
            laiyuan = "百度广告1";
        }
        if ("94".equals(laiyuan)) {
            laiyuan = "百度广告2";
        }
        if ("155".equals(laiyuan)) {
            laiyuan = "抖音广告";
        }
        if ("191".equals(laiyuan)) {
            laiyuan = "腾讯广告";
        }

        customer.setRemark(laiyuan + "/" + jsonObject.getString("remarks"));
        if (null != jsonObject.getInteger("n1")) {
            customer.setAge(jsonObject.getInteger("n1"));
        }
        return customerService.savePushCustomer(customer);
    }


    /**
     * 已接通
     *
     * @param jsonObject
     * @return
     */
    @Log(title = "聚网撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJuWangCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> insertJuWangCheck(@RequestBody JSONObject jsonObject) {
        Map<String, Object> result = new HashMap<String, Object>();
        String phoneMd5 = jsonObject.getString("tel");
        Customer customer = new Customer();
        customer.setPhoneMD5(phoneMd5);
        List<Customer> customers = customerService.findList(customer);
        if (!customers.isEmpty()) {
            for (Customer cus : customers) {
                customerService.updateStatusIfExistedAfterCheck(cus, "聚网", cus.getPhone(), customers.size());
            }
            result.put("code", 201);
            result.put("status", false);
        } else {
            result.put("code", 200);
            result.put("status", true);
        }
        return result;
    }

    /**
     * 已接通 8
     *
     * @param customer
     * @return
     */
    @Log(title = "通联沃数客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertLianTongWoShu", method = RequestMethod.POST)
    @ResponseBody
    public Map insertLianTongWoShu(@RequestBody Customer customer) {
        customer.setLaiyuan("通联沃数");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 9
     *
     * @param customer
     * @return
     */
    @Log(title = "优搜客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertYouSou", method = RequestMethod.POST)
    @ResponseBody
    public Map insertYouSou(@RequestBody Customer customer) {
        customer.setLaiyuan("优搜");
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 10 通用
     *
     * @param customer
     * @return
     */
    @Log(title = "客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomer", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomer(@RequestBody Customer customer) {
        String city = customer.getCityName();
        String citys[] = city.split("-");
        if (citys.length == 2) {
            customer.setCityName(citys[1].replace("市", ""));
        } else {
            customer.setCityName(city.replace("市", ""));
        }
        return customerService.savePushCustomer(customer);
    }

    /**
     * 已接通 10 通用
     *
     * @param customer
     * @return
     */
    @Log(title = "客户推送信息-117", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertJuLiang", method = RequestMethod.POST)
    @ResponseBody
    public Map insertJuLiang(@RequestBody Customer customer) {
        String city = customer.getCityName();
        String citys[] = city.split("-");
        if (citys.length == 2) {
            customer.setCityName(citys[1].replace("市", ""));
        } else {
            customer.setCityName(city.replace("市", ""));
        }
//        boolean isChange=false;
//        String[] cityNames={"九江","宜春","萍乡","新余"};
//        for (String cityName:cityNames){
//            if (cityName.equals(customer.getCityName())){
//                isChange=true;
//                break;
//            }
//        }
//        if(isChange){
//            customer.setRemark(customer.getRemark()+"/原城市："+customer.getCityName());
//            customer.setCityName("南昌");
//        }
        customer.setLaiyuan("巨量H");

        return customerService.savePushCustomer(customer);
    }

    /**
     * 客户信息撞库查询 11 通用
     *
     * @param customer
     * @return
     */
    @Log(title = "客户信息撞库查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerCheck(@RequestBody Customer customer) {
        Map<String, Object> map = new HashMap<>();
        if (StringUtils.isNotEmpty(customer.getPhone()) || StringUtils.isNotEmpty(customer.getPhoneMD5())) {
            Customer customerExist = customerService.findCustomerByphone(customer, false);
            map.put("code", "200");
            if (customerExist != null) {
                map.put("data", false);
                map.put("msg", "客户信息存在");
            } else {
                map.put("data", true);
                map.put("msg", "客户信息不存在");
            }
        } else {
            map.put("code", "500");
            map.put("msg", "手机号或手机号MD5不能为空");
            map.put("data", false);
        }
        return map;
    }

    /**
     * 已接通 10
     *
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-车银", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCheDiRong", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCheDiRong(@RequestBody JSONObject param) throws Exception {

        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String dataRes = AESUtils.Decrypt(param.getString("data"), "kzhtybx8qzmjrc06");
            JSONObject jsonObject = JSONObject.parseObject(dataRes);
            if (null != jsonObject) {
                Customer customer = new Customer();
                customer.setAmount(jsonObject.getString("amount"));
                customer.setCityName(jsonObject.getString("cityName"));
                customer.setCarStatus(jsonObject.getString("carStatus"));
                customer.setCusName(jsonObject.getString("cusName"));
                customer.setPhone(jsonObject.getString("phone"));
                customer.setLaiyuan("车银");
                customer.setCusCanal(jsonObject.getString("dc"));
//                customer.setRemark(customer.getCusBody()+"/"+customer.getCusCanal()+"/"+customer.getRemark());
                return customerService.savePushCustomer(customer);
            } else {
                map.put("code", "500");
                map.put("message", "json is error");
            }
        } else {

            map.put("code", "500");
            map.put("message", "data is null");

        }
        return map;
    }

    /**
     * 融享客线索API
     *
     * @param param
     * @return
     */
    @Log(title = "融享客线索API", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertRongXiangKeOrderCustomer", method = RequestMethod.POST)
    @ResponseBody
    public JSONObject insertRongXiangKeOrderCustomer(@RequestBody JSONObject param) throws Exception {
        JSONObject returnJson = new JSONObject();
        if (StringUtils.isEmpty(param.getString("orderNo"))) {
            returnJson.put("code", 4000);
            returnJson.put("message", "orderNo is null");
            return returnJson;
        }
        RxkOrder rxkOrder = rxkOrderService.get(param.getString("orderNo"));
        if (null != rxkOrder) {
            returnJson.put("code", 5000);
            returnJson.put("message", "orderNo is verb");
            return returnJson;
        } else {
            rxkOrder = new RxkOrder();
            rxkOrder.setId(param.getString("orderNo"));
            rxkOrder.setIsNewRecord();
            rxkOrder.setOrderNo(param.getString("orderNo"));
            rxkOrder.setStatus("0");
        }


        String get_url = "https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/readClues";
        String voucherCode = "3AIIJYJMI3UHVS5D";
        String key = "5BPZ3OLV41U8HB5L";
        String orderNo = param.getString("orderNo");
        JSONObject params = new JSONObject();
        params.put("voucherCode", voucherCode);
        params.put("orderNo", orderNo);
        JSONObject jsonObject = JSONObject.parseObject(HttpUtils.doPost(get_url, params));
        if ("1".equals(jsonObject.getString("code"))) {
            JSONArray customerJsonList = JSONObject.parseArray(RAESUtils.decrypt(jsonObject.getString("data"), key));
            for (int i = 0; i < customerJsonList.size(); i++) {
                JSONObject customerJson = customerJsonList.getJSONObject(i);
                if (null != customerJson) {
                    rxkOrder.setStatus("1"); // 读取成功
                    Customer customer = new Customer();
                    customer.setLaiyuan("融享客");
                    customer.setClueId(customerJson.getString("orderNo"));
                    customer.setCusCanal(customerJson.getString("source"));
                    customer.setCusBody(customerJson.getString("cstSource"));
                    customer.setCusName(customerJson.getString("name"));
                    customer.setAge(customerJson.getInteger("age"));
                    customer.setRemark(customerJson.getString("productName"));
                    customer.setPhone(customerJson.getString("phone"));
                    customer.setSex(customerJson.getInteger("sex") == 0 ? "女" : "男");
                    customer.setCityName(customerJson.getString("city"));

                    Optional.ofNullable(customerJson.getInteger("profession")).ifPresent(v -> {
                        switch (customerJson.getInteger("profession")) {
                            case 200:
                                customer.setWorks("上班族");
                                break;
                            case 300:
                                customer.setWorks("自由职业");
                                break;
                            case 400:
                                customer.setWorks("企业主");
                                break;
                            case 500:
                                customer.setWorks("个体户");
                                break;
                            case 800:
                                customer.setWorks("公务员");
                                break;
                            case 900:
                                customer.setWorks("其他");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("incomeMonth")).ifPresent(v -> {
                        customer.setIncomeMonth(customerJson.getInteger("incomeMonth") + "");
                    });


                    Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                        switch (customerJson.getInteger("sesameScore")) {
                            case 0:
                                customer.setSesameScore("无芝麻分");
                                break;
                            case 10:
                                customer.setSesameScore("600分以下");
                                break;
                            case 20:
                                customer.setSesameScore("600~650分");
                                break;
                            case 30:
                                customer.setSesameScore("650~700分");
                                break;
                            case 40:
                                customer.setSesameScore("700分以上");
                                break;
                        }

                    });
                    Optional.ofNullable(customerJson.getString("loanMoney")).ifPresent(v -> {
                        customer.setAmount(customerJson.getString("loanMoney").substring(0, customerJson.getString(
                                "loanMoney").indexOf(".")) + "万元");
                    });

                    Optional.ofNullable(customerJson.getInteger("loanExpiresMonth")).ifPresent(v -> {
                        customer.setLoanExpiresMonth(customerJson.getInteger("loanExpiresMonth"));
                    });

                    Optional.ofNullable(customerJson.getInteger("loanUse")).ifPresent(v -> {
                        // 有值的处理逻辑
                        switch (customerJson.getInteger("loanUse")) {

                            case 10:
                                customer.setLoanUse("消费贷");
                                break;
                            case 20:
                                customer.setLoanUse("结婚贷");
                                break;
                            case 30:
                                customer.setLoanUse("购房贷");
                                break;
                            case 40:
                                customer.setLoanUse("装修贷");
                                break;
                            case 50:
                                customer.setLoanUse("购车贷");
                                break;
                            case 60:
                                customer.setLoanUse("教育贷");
                                break;
                            case 70:
                                customer.setLoanUse("旅游贷");
                                break;
                            case 80:
                                customer.setLoanUse("医疗贷");
                                break;
                            case 90:
                                customer.setLoanUse("其他贷");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("gjjScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("gjjScop")) {
                            case 0:
                                customer.setAccumulation("无公积金");
                                break;
                            case 10:
                                customer.setAccumulation("缴纳未满6个月");
                                break;
                            case 20:
                                customer.setAccumulation("缴纳6个月以上");
                                break;
                        }
                    });


                    Optional.ofNullable(customerJson.getInteger("sbScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("sbScop")) {
                            case 0:
                                customer.setSocial("无社保");
                                break;
                            case 10:
                                customer.setSocial("缴纳未满6个月");
                                break;
                            case 20:
                                customer.setSocial("缴纳6个月以上");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("house")).ifPresent(v -> {
                        switch (customerJson.getInteger("house")) {
                            case 0:
                                customer.setHouseType("无房产");
                                break;
                            case 10:
                                customer.setHouseType("有房产，不抵押");
                                break;
                            case 20:
                                customer.setHouseType("有房产，可抵押");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("car")).ifPresent(v -> {
                        switch (customerJson.getInteger("car")) {
                            case 0:
                                customer.setCarStatus("无车产");
                                break;
                            case 10:
                                customer.setCarStatus("有车产，不抵押");
                                break;
                            case 20:
                                customer.setCarStatus("有车产，可抵押");
                                break;
                        }

                    });

                    Optional.ofNullable(customerJson.getInteger("baodanScop")).ifPresent(v -> {

                        switch (customerJson.getInteger("baodanScop")) {
                            case 0:
                                customer.setBaodanScop("无保险保单");
                                break;
                            case 10:
                                customer.setBaodanScop("缴纳未满1年");
                                break;
                            case 20:
                                customer.setBaodanScop("缴纳1年以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("credit")).ifPresent(v -> {

                        switch (customerJson.getInteger("credit")) {
                            case 0:
                                customer.setZx("无信用记录");
                                break;
                            case 10:
                                customer.setZx("信用良好无逾期");
                                break;
                            case 20:
                                customer.setZx("2年内逾期少于9次无90天以上逾期");
                                break;
                            case 30:
                                customer.setZx("2年内逾期少于9次有90天以上逾期");
                                break;
                            case 40:
                                customer.setZx("2年内逾期大于9次");
                                break;
                            case 50:
                                customer.setZx("半年内有60天以上逾期");
                                break;
                            case 60:
                                customer.setZx("半年内无60天以上逾期");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("isLoans")).ifPresent(v -> {
                        switch (customerJson.getInteger("isLoans")) {
                            case 0:
                                customer.setIsLoans("无微粒贷");
                                break;
                            case 10:
                                customer.setIsLoans("1~2千");
                                break;
                            case 20:
                                customer.setIsLoans("2~5千");
                                break;
                            case 30:
                                customer.setIsLoans("5千~1万");
                                break;
                            case 40:
                                customer.setIsLoans("1万以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("manageYears")).ifPresent(v -> {
                        switch (customerJson.getInteger("manageYears")) {

                            case 10:
                                customer.setManageYears("1年以下");
                                break;
                            case 20:
                                customer.setManageYears("1年至5年");
                                break;
                            case 30:
                                customer.setManageYears("5年以上");
                                break;

                        }
                    });
                    Optional.ofNullable(customerJson.getString("turnover")).ifPresent(v -> {
                        customer.setTurnover(customerJson.getString("turnover"));
                    });
                    Optional.ofNullable(customerJson.getString("turnoverPublic")).ifPresent(v -> {
                        customer.setTurnoverPublic(customerJson.getString("turnoverPublic"));
                    });
                    Optional.ofNullable(customerJson.getInteger("workingYears")).ifPresent(v -> {
                        switch (customerJson.getInteger("workingYears")) {
                            case 10:
                                customer.setWorkingYears("0~6个月");
                                break;
                            case 20:
                                customer.setWorkingYears("6~12个月");
                                break;
                            case 30:
                                customer.setWorkingYears("12个月以上");
                                break;
                        }
                    });
                    Optional.ofNullable(customerJson.getInteger("registAddress")).ifPresent(v -> {
                        customer.setRegistAddress(customerJson.getInteger("registAddress") == 10 ? "本地" : "外地");
                    });
                    Optional.ofNullable(customerJson.getInteger("hasBusinessLicense")).ifPresent(v -> {
                        switch (customerJson.getInteger("hasBusinessLicense")) {
                            case 0:
                                customer.setHasBusinessLicense("未注册");
                                break;
                            case 10:
                                customer.setHasBusinessLicense("注册1年以下");
                                break;
                            case 20:
                                customer.setHasBusinessLicense("注册1至5年");
                                break;
                            case 30:
                                customer.setHasBusinessLicense("注册5年以上");
                                break;
                        }
                    });

                    Optional.ofNullable(customerJson.getInteger("creditCard")).ifPresent(v -> {
                        customer.setCreditCard(customerJson.getInteger("creditCard") == 0 ? "无信用卡" : "有信用卡");
                    });
                    Optional.ofNullable(customerJson.getString("apiSourceName")).ifPresent(v -> {
                        customer.setApiSourceName(customerJson.getString("apiSourceName"));
                    });
                    Optional.ofNullable(customerJson.getString("followUserName")).ifPresent(v -> {
                        customer.setFollowUserName(customerJson.getString("followUserName"));
                    });
                    Optional.ofNullable(customerJson.getString("brand")).ifPresent(v -> {
                        customer.setBrand(customerJson.getString("brand"));
                    });

                    Map map = customerService.savePushCustomer(customer);
                    if (map.get("code").equals("200")) {
                        String return_url = "https://gw.youxinsign.com/rxk-saas/api/organ-clue-api/updateClueStatus";
                        params = new JSONObject();
                        params.put("voucherCode", voucherCode);
                        params.put("orderNo", orderNo);
                        params.put("status", 1);
                        params.put("remark", map.get("message"));
                        returnJson = JSONObject.parseObject(HttpUtils.doPost(return_url, params));
                    } else {
                        returnJson.put("code", map.get("code"));
                        returnJson.put("message", map.get("message"));
                    }
                }
            }
        }

        rxkOrderService.save(rxkOrder);
        returnJson.put("code", 200);
        returnJson.put("message", "success");
        return returnJson;
    }

    /**
     * 吉客
     *
     * @param params
     * @return
     */
    @Log(title = "吉客客户信息准入查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerIsCheck(@RequestBody JSONObject params) {
        Map<String, Object> map = new HashMap<>();
        String merchantNo = "H5394647689828";// 商户号
        if (!merchantNo.equals(params.getString("merchantNo"))) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "商户号错误");
            return map;
        }
        String data = params.getString("data");// 加密的串
        String keyAes = "f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);

        } catch (Exception e) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密失败");
            return map;
        }
        JSONObject jsonObject = JSONObject.parseObject(data);
        if (StringUtils.isNull(jsonObject)) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密数据为空");
            return map;
        }
        if (null != jsonObject) {
            Customer customer = new Customer();
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhoneMD5(jsonObject.getString("phoneNo"));
            });
            List<Customer> customers = customerService.findList(customer);
            if (null != customers && !customers.isEmpty()) {
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, "吉客", cus.getPhone(), customers.size());
                }
                map.put("dealStatus", "9999");
                map.put("dealDesc", "客户信息重复");
            } else {
                map.put("dealStatus", "0000");
                map.put("dealDesc", "客户可入库");
            }
        }
        return map;
    }

    /**
     * 吉客A
     *
     * @param params
     * @return
     */
    @Log(title = "吉客A客户信息准入查询", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeOtherIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeOtherIsCheck(@RequestBody JSONObject params) {
        Map<String, Object> map = new HashMap<>();
        String merchantNo = "H7181163174754";// 商户号
        if (!merchantNo.equals(params.getString("merchantNo"))) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "商户号错误");
            return map;
        }
        String data = params.getString("data");// 加密的串
        String keyAes = "f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);

        } catch (Exception e) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密失败");
            return map;
        }
        JSONObject jsonObject = JSONObject.parseObject(data);
        if (StringUtils.isNull(jsonObject)) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密数据为空");
            return map;
        }
        if (null != jsonObject) {
            Customer customer = new Customer();

            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhoneMD5(jsonObject.getString("phoneNo"));
            });

            List<Customer> customers = customerService.findList(customer);
            if (null != customers && !customers.isEmpty()) {
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, "吉客A", cus.getPhone(), customers.size());
                }
                map.put("dealStatus", "9999");
                map.put("dealDesc", "客户信息重复");
            } else {
                map.put("dealStatus", "0000");
                map.put("dealDesc", "客户可入库");
            }

        }
        return map;
    }

    /**
     * 吉客A
     *
     * @param
     * @return
     */
    @Log(title = "吉客A客户信息推送", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeOtherInsert", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeOtherInsert(@RequestBody JSONObject params) {
        Map<String, Object> map = new HashMap<>();
        String merchantNo = "H7181163174754";// 商户号
        if (!merchantNo.equals(params.getString("merchantNo"))) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "商户号错误");
            return map;
        }
        String data = params.getString("data");// 加密的串

        String keyAes = "f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);
        } catch (Exception e) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密失败");
            return map;
        }
        JSONObject jsonObject = JSONObject.parseObject(data);
        if (StringUtils.isNull(jsonObject)) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密数据为空");
            return map;
        }
        if (null != jsonObject) {
            Customer customer = new Customer();
            customer.setLaiyuan("吉客A");
            Optional.ofNullable(jsonObject.getString("applyId")).ifPresent(v -> {
                customer.setClueId(jsonObject.getString("applyId"));
            });
            Optional.ofNullable(jsonObject.getString("custName")).ifPresent(v -> {
                customer.setCusName(jsonObject.getString("custName"));
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(jsonObject.getString("city"));
            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhone(jsonObject.getString("phoneNo"));
            });
            Optional.ofNullable(jsonObject.getString("sex")).ifPresent(v -> {
                switch (jsonObject.getString("sex")) {
                    case "1":
                        customer.setSex("男");
                        break;
                    case "2":
                        customer.setSex("女");
                        break;
                    default:
                        customer.setSex("未知");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("age")).ifPresent(v -> {
                customer.setAge(Integer.parseInt(jsonObject.getString("age")));
            });
            Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(v -> {
                switch (jsonObject.getString("loanAmount")) {
                    case "1":
                        customer.setAmount("0-3万");
                        break;
                    case "2":
                        customer.setAmount("3-5万");
                        break;
                    case "3":
                        customer.setAmount("5-10万");
                        break;
                    case "4":
                        customer.setAmount("10-20万");
                        break;
                    case "5":
                        customer.setAmount("20万以上");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("profession")).ifPresent(v -> {
                switch (jsonObject.getString("profession")) {
                    case "1":
                        customer.setWorks("自由职业");
                        break;
                    case "2":
                        customer.setWorks("上班族");
                        break;
                    case "3":
                        customer.setWorks("个体户");
                        break;
                    case "4":
                        customer.setWorks("企业户");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("salaryType")).ifPresent(v -> {
                switch (jsonObject.getString("salaryType")) {
                    case "1":
                        customer.setPayoffType("现金");
                        break;
                    case "2":
                        customer.setPayoffType("打卡工资");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("socialSecurity")).ifPresent(v -> {
                switch (jsonObject.getString("socialSecurity")) {
                    case "1":
                        customer.setSocial("6个月下");
                        break;
                    case "2":
                        customer.setSocial("6个月上");
                        break;
                    case "0":
                        customer.setSocial("无");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("providentFund")).ifPresent(v -> {
                switch (jsonObject.getString("providentFund")) {
                    case "1":
                        customer.setAccumulation("6个月下");
                        break;
                    case "2":
                        customer.setAccumulation("6个月上");
                        break;
                    case "0":
                        customer.setAccumulation("无");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getString("car")).ifPresent(v -> {
                switch (jsonObject.getString("car")) {
                    case "1":
                        customer.setCarStatus("有按揭车");
                        break;
                    case "2":
                        customer.setCarStatus("有全款车");
                        break;
                    case "0":
                        customer.setCarStatus("无车");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("estate")).ifPresent(v -> {
                switch (jsonObject.getString("estate")) {
                    case "1":
                        customer.setHouseType("有按揭商品房");
                        break;
                    case "2":
                        customer.setHouseType("有全款商品房");
                        break;
                    case "0":
                        customer.setHouseType("无房产");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("creditCardLimit")).ifPresent(v -> {
                switch (jsonObject.getString("creditCardLimit")) {
                    case "1":
                        customer.setCreditCard("3000以下");
                        break;
                    case "2":
                        customer.setCreditCard("3000-5000元");
                        break;
                    case "3":
                        customer.setCreditCard("5000-10000元");
                        break;
                    case "4":
                        customer.setCreditCard("10000元以上");
                        break;
                    case "0":
                        customer.setCreditCard("无信用卡");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("zhiMaScore")).ifPresent(v -> {
                switch (jsonObject.getString("zhiMaScore")) {
                    case "1":
                        customer.setSesameScore("600-650分");
                        break;
                    case "2":
                        customer.setSesameScore("650-700分");
                        break;
                    case "3":
                        customer.setSesameScore("700分以上");
                        break;
                    case "0":
                        customer.setSesameScore("无芝麻分");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("lifeInsurance")).ifPresent(v -> {
                switch (jsonObject.getString("lifeInsurance")) {
                    case "1":
                        customer.setPolicy("有保单");
                        break;
                    case "0":
                        customer.setPolicy("无保单");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("monthIncome")).ifPresent(v -> {
                customer.setIncomeMonth(jsonObject.getString("monthIncome"));
            });

            Optional.ofNullable(jsonObject.getString("loanPurpose")).ifPresent(v -> {
                switch (jsonObject.getString("loanPurpose")) {
                    case "1":
                        customer.setLoanUse("日常消费");
                        break;
                    case "2":
                        customer.setLoanUse("装修");
                        break;
                    case "3":
                        customer.setLoanUse("旅游");
                        break;
                    case "4":
                        customer.setLoanUse("教育培训");
                        break;
                    case "5":
                        customer.setLoanUse("婚庆");
                }
            });


            Optional.ofNullable(jsonObject.getString("fromIp")).ifPresent(v -> {
                customer.setIp(jsonObject.getString("fromIp"));
            });
            Optional.ofNullable(jsonObject.getString("loanTerm")).ifPresent(v -> {
                String loanTerm = "";
                switch (jsonObject.getString("loanTerm")) {
                    case "01":
                        loanTerm = "1年以内";
                        break;
                    case "02":
                        loanTerm = "1-3年以内";
                        break;
                    case "03":
                        loanTerm = "3年以上";
                        break;
                }
                customer.setRemark("借款周期：" + loanTerm);
            });
            Optional.ofNullable(jsonObject.getString("degree")).ifPresent(v -> {
                String degree = "";
                switch (jsonObject.getString("degree")) {
                    case "1":
                        degree = "高中及一下";
                        break;
                    case "2":
                        degree = "大专";
                        break;
                    case "3":
                        degree = "本科及以上";
                        break;
                }
                customer.setRemark(customer.getRemark() + "/学历：" + degree);
            });
            Optional.ofNullable(jsonObject.getString("answeringTime")).ifPresent(v -> {
                String answeringTime = jsonObject.getString("answeringTime");
                customer.setRemark(customer.getRemark() + "/方便接听时间：：" + answeringTime);
            });

            Map maps = customerService.savePushCustomer(customer);
            if (maps.get("code").equals("200")) {
                map.put("dealStatus", "0000");
            } else {
                map.put("dealStatus", "9999");
                map.put("dealDesc", maps.get("message"));
            }
        }
        return map;
    }

    /**
     * 吉客
     *
     * @param
     * @return
     */
    @Log(title = "吉客客户信息推送", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/customerJiKeInsert", method = RequestMethod.POST)
    @ResponseBody
    public Map customerJiKeInsert(@RequestBody JSONObject params) {
        Map<String, Object> map = new HashMap<>();
        String merchantNo = "H5394647689828";// 商户号
        if (!merchantNo.equals(params.getString("merchantNo"))) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "商户号错误");
            return map;
        }
        String data = params.getString("data");// 加密的串

        String keyAes = "f6c246d000e945a49dbd4e95d4887f46";
        try {
            // 解密
            data = Base64Util.decrypt(data, keyAes);
        } catch (Exception e) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密失败");
            return map;
        }
        JSONObject jsonObject = JSONObject.parseObject(data);
        if (StringUtils.isNull(jsonObject)) {
            map.put("dealStatus", "9999");
            map.put("dealDesc", "data解密数据为空");
            return map;
        }
        if (null != jsonObject) {
            Customer customer = new Customer();
            customer.setLaiyuan("吉客");
            Optional.ofNullable(jsonObject.getString("applyId")).ifPresent(v -> {
                customer.setClueId(jsonObject.getString("applyId"));
            });
            Optional.ofNullable(jsonObject.getString("custName")).ifPresent(v -> {
                customer.setCusName(jsonObject.getString("custName"));
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(jsonObject.getString("city"));
            });
            Optional.ofNullable(jsonObject.getString("phoneNo")).ifPresent(v -> {
                customer.setPhone(jsonObject.getString("phoneNo"));
            });
            Optional.ofNullable(jsonObject.getString("sex")).ifPresent(v -> {
                switch (jsonObject.getString("sex")) {
                    case "1":
                        customer.setSex("男");
                        break;
                    case "2":
                        customer.setSex("女");
                        break;
                    default:
                        customer.setSex("未知");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("age")).ifPresent(v -> {
                customer.setAge(Integer.parseInt(jsonObject.getString("age")));
            });
            Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(v -> {
                switch (jsonObject.getString("loanAmount")) {
                    case "1":
                        customer.setAmount("0-3万");
                        break;
                    case "2":
                        customer.setAmount("3-5万");
                        break;
                    case "3":
                        customer.setAmount("5-10万");
                        break;
                    case "4":
                        customer.setAmount("10-20万");
                        break;
                    case "5":
                        customer.setAmount("20万以上");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("profession")).ifPresent(v -> {
                switch (jsonObject.getString("profession")) {
                    case "1":
                        customer.setWorks("自由职业");
                        break;
                    case "2":
                        customer.setWorks("上班族");
                        break;
                    case "3":
                        customer.setWorks("个体户");
                        break;
                    case "4":
                        customer.setWorks("企业户");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("salaryType")).ifPresent(v -> {
                switch (jsonObject.getString("salaryType")) {
                    case "1":
                        customer.setPayoffType("现金");
                        break;
                    case "2":
                        customer.setPayoffType("打卡工资");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("socialSecurity")).ifPresent(v -> {
                switch (jsonObject.getString("socialSecurity")) {
                    case "1":
                        customer.setSocial("6个月下");
                        break;
                    case "2":
                        customer.setSocial("6个月上");
                        break;
                    case "0":
                        customer.setSocial("无");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("providentFund")).ifPresent(v -> {
                switch (jsonObject.getString("providentFund")) {
                    case "1":
                        customer.setAccumulation("6个月下");
                        break;
                    case "2":
                        customer.setAccumulation("6个月上");
                        break;
                    case "0":
                        customer.setAccumulation("无");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getString("car")).ifPresent(v -> {
                switch (jsonObject.getString("car")) {
                    case "1":
                        customer.setCarStatus("有按揭车");
                        break;
                    case "2":
                        customer.setCarStatus("有全款车");
                        break;
                    case "0":
                        customer.setCarStatus("无车");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("estate")).ifPresent(v -> {
                switch (jsonObject.getString("estate")) {
                    case "1":
                        customer.setHouseType("有按揭商品房");
                        break;
                    case "2":
                        customer.setHouseType("有全款商品房");
                        break;
                    case "0":
                        customer.setHouseType("无房产");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("creditCardLimit")).ifPresent(v -> {
                switch (jsonObject.getString("creditCardLimit")) {
                    case "1":
                        customer.setCreditCard("3000以下");
                        break;
                    case "2":
                        customer.setCreditCard("3000-5000元");
                        break;
                    case "3":
                        customer.setCreditCard("5000-10000元");
                        break;
                    case "4":
                        customer.setCreditCard("10000元以上");
                        break;
                    case "0":
                        customer.setCreditCard("无信用卡");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("zhiMaScore")).ifPresent(v -> {
                switch (jsonObject.getString("zhiMaScore")) {
                    case "1":
                        customer.setSesameScore("600-650分");
                        break;
                    case "2":
                        customer.setSesameScore("650-700分");
                        break;
                    case "3":
                        customer.setSesameScore("700分以上");
                        break;
                    case "0":
                        customer.setSesameScore("无芝麻分");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("lifeInsurance")).ifPresent(v -> {
                switch (jsonObject.getString("lifeInsurance")) {
                    case "1":
                        customer.setPolicy("有保单");
                        break;
                    case "0":
                        customer.setPolicy("无保单");
                        break;
                }
            });
            Optional.ofNullable(jsonObject.getString("monthIncome")).ifPresent(v -> {
                customer.setIncomeMonth(jsonObject.getString("monthIncome"));
            });
            Optional.ofNullable(jsonObject.getString("carNum")).ifPresent(v -> {
                customer.setCarNo(jsonObject.getString("carNum"));
            });

            Optional.ofNullable(jsonObject.getString("loanPurpose")).ifPresent(v -> {
                switch (jsonObject.getString("loanPurpose")) {
                    case "1":
                        customer.setLoanUse("日常消费");
                        break;
                    case "2":
                        customer.setLoanUse("装修");
                        break;
                    case "3":
                        customer.setLoanUse("旅游");
                        break;
                    case "4":
                        customer.setLoanUse("教育培训");
                        break;
                    case "5":
                        customer.setLoanUse("婚庆");
                }
            });

            Optional.ofNullable(jsonObject.getInteger("carCost")).ifPresent(v -> {
                switch (v) {
                    case 1:
                        customer.setPgPrice("3万以下");
                        break;
                    case 2:
                        customer.setPgPrice("3-10万");
                        break;
                    case 3:
                        customer.setPgPrice("10万以上");
                        break;
                }
            });

            Optional.ofNullable(jsonObject.getInteger("carAge")).ifPresent(v -> {
                customer.setCarAge(v == 1 ? "10年以内" : "10年以上");
            });

            Optional.ofNullable(jsonObject.getInteger("carMortgage")).ifPresent(v -> {
                customer.setRemark(v == 1 ? "未抵押" : "抵押中");
            });

            Map maps = customerService.savePushCustomer(customer);
            if (maps.get("code").equals("200")) {
                map.put("dealStatus", "0000");
            } else {
                map.put("dealStatus", "9999");
                map.put("dealDesc", maps.get("message"));
            }
        }
        return map;
    }

    /**
     * 已接通 16 惠融
     *
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-惠融", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByHuiRong", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByHuiRong(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String dataRes = AESUtils.Decrypt(param.getString("data"), "kzhtybx8qzmjrc06");
            JSONObject jsonObject = JSONObject.parseObject(dataRes);
            if (null != jsonObject) {
                Customer customer = new Customer();
                customer.setAmount(jsonObject.getString("amount"));
                customer.setCityName(jsonObject.getString("cityName"));
                customer.setCarStatus(jsonObject.getString("carStatus"));
                customer.setCusName(jsonObject.getString("cusName"));
                customer.setPhone(jsonObject.getString("phone"));
                customer.setCarModel(jsonObject.getString("carModel"));
                customer.setCarAge(jsonObject.getString("carAge"));
                customer.setCusCanal(jsonObject.getString("dc"));
                customer.setRemark(jsonObject.getString("remark"));
                customer.setLaiyuan("惠融");
                return customerService.savePushCustomer(customer);
            } else {
                map.put("code", "500");
                map.put("message", "json is error");
            }
        } else {

            map.put("code", "500");
            map.put("message", "data is null");

        }
        return map;
    }

    /**
     * 已接通 16 惠融撞库
     *
     * @param param
     * @return
     */
    @Log(title = "客户推送信息-惠融撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByHuiRongIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByHuiRongIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "惠融";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String dataRes = AESUtils.Decrypt(param.getString("data"), "kzhtybx8qzmjrc06");
            JSONObject jsonObject = JSONObject.parseObject(dataRes);
            if (null != jsonObject) {
                String phone = jsonObject.getString("phone");
                Customer customer = new Customer();
                customer.setPhone(phone);
                List<Customer> customers = customerService.findList(customer);
                if (!customers.isEmpty()) {
                    for (Customer cus : customers) {
                        customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    }
                    map.put("code", "201");
                    map.put("message", "客户存在，不准入");
                } else {
                    map.put("code", "200");
                    map.put("message", "准入客户");
                }
            } else {
                map.put("code", "500");
                map.put("message", "json is error");
            }
        } else {

            map.put("code", "500");
            map.put("message", "data is null");

        }
        return map;
    }

    /**
     * 融享客-撞库
     *
     * @param param
     * @return
     */
    @Log(title = "融享客客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRongXiangKeIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRongXiangKeIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "融享客";
        Map<String, Object> map = new HashMap<String, Object>();
        if (StringUtils.isNotEmpty(param.getString("phone"))) {
            String phone = RongXiangKeAESUtil.decrypt(param.getString("phone"), RongXiangKeAESUtil.KEY);
            phone = phone.substring(0, 8);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            List<String> list = new ArrayList<>();
            for (Customer cus : customers) {
                customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            /**
             * 宁波-撞库
             */
//            list = NingBoIsCheckCustomerList(list, Ning_Bo_URL + "/insertCustomerByRongXiangKeIsCheck", param,
//            "data");
            map.put("code", 200);
            map.put("data", list);
            map.put("msg", "成功");
            return map;
        } else {
            map.put("code", "401");
            map.put("msg", "phone is null");
        }
        return map;
    }

    /**
     * 橙易通A
     *
     * @param param
     * @return
     */
    @Log(title = "橙易通A客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "橙易通A";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String phone = AESUtils.Decrypt(param.getString("data"), "hbt4j8ql7n7yjtfb");
            if (null == phone) {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            JSONObject jsonObject = JSONObject.parseObject(phone);
            if (null != jsonObject) {
                phone = jsonObject.getString("phone");
            } else {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            phone = phone.substring(0, 8);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            List<String> list = new ArrayList<>();
            for (Customer cus : customers) {
                customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            map.put("code", 200);
            map.put("data", list);
            map.put("msg", "成功");
            return map;
        } else {
            map.put("code", "401");
            map.put("msg", "phone is null");
        }
        return map;
    }

    /**
     * 橙易通A
     *
     * @param param
     * @return
     */
    @Log(title = "橙易通A客户推送信息-推送接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytPush", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytPush(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String json = AESUtils.Decrypt(param.getString("data"), "hbt4j8ql7n7yjtfb");
            if (null == json) {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            JSONObject jsonObject = JSONObject.parseObject(json);
            if (null != jsonObject) {
                Customer customer = new Customer();
                customer.setLaiyuan("橙易通A");
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("gender")).ifPresent(v -> {
                    customer.setSex(v);
                });
                Optional.ofNullable(jsonObject.getString("ip")).ifPresent(v -> {
                    customer.setIp(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                Optional.ofNullable(jsonObject.getInteger("profession")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setWorks("上班族");
                            break;
                        case 2:
                            customer.setWorks("自由职业");
                            break;
                        case 3:
                            customer.setWorks("企业主");
                            break;
                        case 4:
                            customer.setWorks("公务员/国企");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAmount("3万-5万");
                            break;
                        case 2:
                            customer.setAmount("5万-10万");
                            break;
                        case 3:
                            customer.setAmount("10万-20万");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("sesameSeed")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setSesameScore("700以上");
                            break;
                        case 2:
                            customer.setSesameScore("650-700");
                            break;
                        case 3:
                            customer.setSesameScore("600-650");
                            break;
                        case 4:
                            customer.setSesameScore("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setSocial("6个月以下");
                            break;
                        case 2:
                            customer.setSocial("6-12个月");
                            break;
                        case 3:
                            customer.setSocial("12个月以上");
                            break;
                        case 4:
                            customer.setSocial("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicle")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setCarStatus("有");
                            break;
                        case 2:
                            customer.setCarStatus("无");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setHouseType("有");
                            break;
                        case 2:
                            customer.setHouseType("无");
                            break;


                    }
                });
                customerService.savePushCustomer(customer);

                map.put("code", 200);
                map.put("msg", "进件成功");
                return map;
            } else {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }

        } else {
            map.put("code", "401");
            map.put("msg", "phone is null");
        }
        return map;
    }

    /**
     * 橙易通
     *
     * @param param
     * @return
     */
    @Log(title = "橙易通客户推送信息-推送接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytNextPush", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytNextPush(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String json = AESUtils.Decrypt(param.getString("data"), "hbt4j8ql7n7yjtfb");
            if (null == json) {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            JSONObject jsonObject = JSONObject.parseObject(json);
            if (null != jsonObject) {
                Customer customer = new Customer();
                customer.setLaiyuan("橙易通CYT");
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("gender")).ifPresent(v -> {
                    customer.setSex(v);
                });
                Optional.ofNullable(jsonObject.getString("ip")).ifPresent(v -> {
                    customer.setIp(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                Optional.ofNullable(jsonObject.getInteger("profession")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setWorks("上班族");
                            break;
                        case 2:
                            customer.setWorks("自由职业");
                            break;
                        case 3:
                            customer.setWorks("企业主");
                            break;
                        case 4:
                            customer.setWorks("公务员/国企");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("loanAmount")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAmount("3万-5万");
                            break;
                        case 2:
                            customer.setAmount("5万-10万");
                            break;
                        case 3:
                            customer.setAmount("10万-20万");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("sesameSeed")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setSesameScore("700以上");
                            break;
                        case 2:
                            customer.setSesameScore("650-700");
                            break;
                        case 3:
                            customer.setSesameScore("600-650");
                            break;
                        case 4:
                            customer.setSesameScore("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setSocial("6个月以下");
                            break;
                        case 2:
                            customer.setSocial("6-12个月");
                            break;
                        case 3:
                            customer.setSocial("12个月以上");
                            break;
                        case 4:
                            customer.setSocial("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("providentFund")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setAccumulation("6个月以下");
                            break;
                        case 2:
                            customer.setAccumulation("6-12个月");
                            break;
                        case 3:
                            customer.setAccumulation("12个月以上");
                            break;
                        case 4:
                            customer.setAccumulation("无");
                            break;

                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleMortgageStatus")).ifPresent(v -> {
                    switch (v) {
                        case 0:
                            customer.setCarStatus("未抵押");
                            break;
                        case 1:
                            customer.setCarStatus("无按揭中");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setHouseType("有");
                            break;
                        case 2:
                            customer.setHouseType("无");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleMortgage")).ifPresent(v -> {
                    switch (v) {
                        case 0:
                            customer.setCarModel("不可抵押");
                            break;
                        case 1:
                            customer.setCarModel("可抵押");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getInteger("vehicleTime")).ifPresent(v -> {
                    switch (v) {
                        case 1:
                            customer.setCarAge("10年以下");
                            break;
                        case 2:
                            customer.setCarModel("10年以上");
                            break;


                    }
                });
                Optional.ofNullable(jsonObject.getString("vehicleCity")).ifPresent(v -> {
                    customer.setCarNo(v);
                });


                customerService.savePushCustomer(customer);

                map.put("code", 200);
                map.put("msg", "进件成功");
                return map;
            } else {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }

        } else {
            map.put("code", "401");
            map.put("msg", "phone is null");
        }
        return map;
    }

    /**
     * 橙易通
     *
     * @param param
     * @return
     */
    @Log(title = "橙易通客户推送信息-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByCytNextIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByCytNextIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "橙易通CYT";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            String phone = AESUtils.Decrypt(param.getString("data"), "hbt4j8ql7n7yjtfb");
            if (null == phone) {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            JSONObject jsonObject = JSONObject.parseObject(phone);
            if (null != jsonObject) {
                phone = jsonObject.getString("phone");
            } else {
                map.put("code", "401");
                map.put("msg", "data is null");
                return map;
            }
            phone = phone.substring(0, 8);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            List<String> list = new ArrayList<>();
            for (Customer cus : customers) {
                customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            map.put("code", 200);
            map.put("data", list);
            map.put("msg", "成功");
            return map;
        } else {
            map.put("code", "401");
            map.put("msg", "phone is null");
        }
        return map;
    }

    /**
     * 融享客-线索通知
     *
     * @param param
     * @return
     */
    @Log(title = "融享客客户推送信息-线索通知", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRongXiangKeOrder", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRongXiangKeOrder(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("orderNo"))) {
            String orderNo = param.getString("orderNo");
            RxkOrder rxkOrder = new RxkOrder();
            rxkOrder.setId(orderNo);
            rxkOrder.setIsNewRecord();
            rxkOrder.setOrderNo(orderNo);
            rxkOrder.setStatus("0");
            try {

                int count = customerService.insertRongXinKe(rxkOrder.getOrderNo());
                if (count == 1) {
                    rxkOrder.setStatus("1");
                    map.put("code", 200);
                    map.put("msg", "通知成功");

                } else {
                    rxkOrderService.save(rxkOrder);
                    map.put("code", 500);
                    map.put("msg", "获取消息失败");
                }

            } catch (Exception e) {
                map.put("code", 500);
                map.put("msg", "通知失败:" + e.getMessage());
            }
            return map;
        } else {
            map.put("code", "401");
            map.put("msg", "orderNo is null");
        }
        return map;
    }

    /**
     * 乐数云客户推送信息 1
     *
     * @param jsonObjects
     * @return
     */
    @Log(title = "乐数云客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertLeShuYun", method = RequestMethod.POST)
    @ResponseBody
    public Map insertLeShuYun(@RequestBody JSONObject[] jsonObjects) {
        Map map = new HashMap();
        List<Map> maps = new ArrayList<>();
        for (int i = 0; i < jsonObjects.length; i++) {
            Customer customer = new Customer();
            customer.setLaiyuan("乐数云");
            JSONObject jsonObject = jsonObjects[i];
            Optional.ofNullable(jsonObject.getString("id")).ifPresent(v -> {
                customer.setClueId(v);
            });
            Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                customer.setCusName(v);
            });
            Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(v -> {
                customer.setPhone(v);
            });
            Optional.ofNullable(jsonObject.getString("expectedAmount")).ifPresent(v -> {
                customer.setAmount(v);
            });
            Optional.ofNullable(jsonObject.getString("launchPlatform")).ifPresent(v -> {
                customer.setRemark(v);
            });
            Optional.ofNullable(jsonObject.getString("situation")).ifPresent(v -> {
                customer.setRemark(customer.getRemark() + "/" + v);
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(v);
            });
            maps.add(customerService.savePushCustomer(customer));
        }
        map.put("maps", maps);
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360IsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360IsCheck(String channel_code, String mobile, String sign, String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
//            String phone= new String(Rong360Codec.base64StrDecode("mWgiBgxlKX6Qvq9v","BgBk0REx0Gx1yIgk",mobile));
            String phone = new String(Rong360Codec.base64StrDecode("CxK9vOWpDHIPcFr4", "YJA5F60ff5N23Rsk", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-上饶", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360ShangRaoIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360ShangRaoIsCheck(String channel_code, String mobile, String sign,
                String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("8wf4r2EODCQY7z0F", "shZU7uNUubQx1F6w", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-吉安", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360JiAnIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360JiAnIsCheck(String channel_code, String mobile, String sign, String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("6ZxOehDCBq9mNgfy", "AkM3FmTHCjhHM7wh", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-抚州", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360FuZhouIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360FuZhouIsCheck(String channel_code, String mobile, String sign,
 String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("MMPFMHKaowMLKya9", "PAceFq15yBKVsgzX", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-九江", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360JiuJiangIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360JiuJiangIsCheck(String channel_code, String mobile, String sign,
     String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("tyDXaN5ZS80uJ08Z", "k8E2eDtgylFluNHM", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-赣州", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360GanZhouIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360GanZhouIsCheck(String channel_code, String mobile, String sign,
 String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("ShUYftzv0o1Y6xxB", "HIoyqF1OBh8zdQVJ", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-宜春", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360YiChunIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360YiChunIsCheck(String channel_code, String mobile, String sign,
                String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("uR2m55YBG8GpCFbE", "PS0MlZadHhrDdN8p", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }

    /**
     * 融360 撞库 宁波
     *
     * @param
     * @return
     */
    @Log(title = "融360撞库-宁波", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByRong360NingBoIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByRong360NingBoIsCheck(String channel_code, String mobile, String sign,
     String timestamp) throws Exception {
        String laiyuan = "融360";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(channel_code) && "rong360".equals(channel_code)) {
            String phone = new String(Rong360Codec.base64StrDecode("l4EAD8OsibGQnoW8", "aN8bKe3hqwhnUQGO", mobile));
            phone = phone.substring(0, 7);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                map.put("code", 1);
                map.put("data", list);
                map.put("msg", "success");
            } else {
                map.put("code", 0);
                map.put("data", null);
                map.put("msg", "fail");
            }

        } else {
            map.put("msg", "channel_code is error");
            map.put("code", -1);
        }
        return map;
    }


    /**
     * 已接通 10 通用
     *
     * @param customer
     * @return
     */
    @Log(title = "群德客户推送信息", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerQunDe", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerQunDe(@RequestBody Customer customer) {
        String city = customer.getCityName();
        String citys[] = city.split("-");
        if (citys.length == 2) {
            customer.setCityName(citys[1].replace("市", ""));
        } else {
            customer.setCityName(city.replace("市", ""));
        }
        return customerService.savePushCustomer(customer);
    }


    /**
     * 通用加密撞库
     *
     * @param
     * @return
     */
    @Log(title = "通用加密撞库", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerAesCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerCheck(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("phone")) && StringUtils.isNotEmpty(param.getString("laiyuan")) && StringUtils.isNotNull(param.getInteger("bytes"))) {
            String phone = param.getString("phone");
            String laiyuan = param.getString("laiyuan");
            Integer bytes = param.getInteger("bytes");
            if (bytes > 11) {
                bytes = 11;
            }
            phone = new String(XunSuBangAesUtils.decrypt(phone, "YJA5F60ff5N23Rsk"));
            phone = phone.substring(0, bytes);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            if (!customers.isEmpty()) {
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                list = NingBoIsCheckCustomerList(list, Ning_Bo_URL + "/insertCustomerAesCheck", param, "data");
                map.put("code", "200");
                map.put("data", list);
                map.put("message", "success");
            } else {
                map.put("code", "200");
                map.put("data", null);
                map.put("message", "success");
            }

        } else {
            map.put("msg", "mobile is null or laiyuan is null or bytes is null ");
            map.put("code", -1);
        }
        return map;
    }

    @Log(title = "通用加密请求", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertAesCustomer", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomer(@RequestBody JSONObject param) throws Exception {
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            JSONObject jsonObject = JSONObject.parseObject(new String(XunSuBangAesUtils.decrypt(param.getString("data"
            ), "YJA5F60ff5N23Rsk")));
            if (StringUtils.isNotNull(jsonObject)) {


                Customer customer = new Customer();
                if (StringUtils.isEmpty(jsonObject.getString("phone"))) {
                    map.put("msg", "手机号不能为空");
                    map.put("code", "500");
                    return map;
                }
                Optional.ofNullable(jsonObject.getString("cusName")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("cityName")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                // 宁波推送-讯速帮
//                if (customer.getCityName().contains("宁波")) {
//                    Map nbMap = new HashMap();
//                    JSONObject jsonNb = NingBoPushCustomer(Ning_Bo_URL + "/insertAesCustomer", param);
//                    if ("200".equals(jsonNb.get("code"))) {
//                        nbMap.put("code", 200);
//                        nbMap.put("message", "成功");
//                    } else {
//                        nbMap.put("code", 500);
//                        nbMap.put("message", "失败");
//                    }
//                    return nbMap;
//                }
                Optional.ofNullable(jsonObject.getString("laiyuan")).ifPresent(v -> {
                    customer.setLaiyuan(v);
                });
                Optional.ofNullable(jsonObject.getString("amount")).ifPresent(v -> {
                    customer.setAmount(v);
                });
                Optional.ofNullable(jsonObject.getString("carModel")).ifPresent(v -> {
                    customer.setCarModel(v);
                });
                Optional.ofNullable(jsonObject.getString("carNo")).ifPresent(v -> {
                    customer.setCarNo(v);
                });
                Optional.ofNullable(jsonObject.getString("carStatus")).ifPresent(v -> {
                    customer.setCarStatus(v);
                });
                Optional.ofNullable(jsonObject.getString("pgPrice")).ifPresent(v -> {
                    customer.setPgPrice(v);
                });
                Optional.ofNullable(jsonObject.getString("accumulation")).ifPresent(v -> {
                    customer.setAccumulation(v);
                });
                Optional.ofNullable(jsonObject.getString("social")).ifPresent(v -> {
                    customer.setSocial(v);
                });
                Optional.ofNullable(jsonObject.getString("houseType")).ifPresent(v -> {
                    customer.setHouseType(v);
                });
                Optional.ofNullable(jsonObject.getString("incomeMonth")).ifPresent(v -> {
                    customer.setIncomeMonth(v);
                });
                Optional.ofNullable(jsonObject.getString("payoffType")).ifPresent(v -> {
                    customer.setPayoffType(v);
                });
                Optional.ofNullable(jsonObject.getString("baodanScop")).ifPresent(v -> {
                    customer.setBaodanScop(v);
                });
                Optional.ofNullable(jsonObject.getString("workingYears")).ifPresent(v -> {
                    customer.setWorkingYears(v);
                });
                Optional.ofNullable(jsonObject.getString("creditCard")).ifPresent(v -> {
                    customer.setCreditCard(v);
                });
                map = customerService.savePushCustomer(customer);
            }
        } else {
            map.put("message", "data 解密失败");
            map.put("code", "500");
        }
        return map;
    }

    /**
     * 放鑫钱包
     *
     * @param param
     * @return
     */
    @Log(title = "放鑫钱包-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByFangXinQianBaoIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByFangXinQianBaoIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "放鑫钱包";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("requestData"))) {
            String requestData = FangXinQianBaoAESUtils.decrypt(FangXinQianBaoAESUtils.KEY,
             FangXinQianBaoAESUtils.KEY, param.getString("requestData"));
            String phone = JSONObject.parseObject(requestData).getString("encryptValue").substring(0, 9);
            Customer customer = new Customer();
            customer.setPhone(phone);
            List<Customer> customers = customerService.findList(customer);
            List<String> list = new ArrayList<>();
            for (Customer cus : customers) {
                customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                list.add(Md5Utils.hash(cus.getPhone()));
            }
            /**
             * 宁波 - 撞库
             */

            try {
                list = NingBoIsCheckCustomerList(list, Ning_Bo_URL + "/insertCustomerByFangXinQianBaoIsCheck", param,
 "data");
            } catch (Exception e) {
                logger.error("--放鑫钱包-宁波撞库异常--", e.getMessage());
            }


            map.put("code", 1);
            map.put("data", list);
            map.put("msg", "成功");
            return map;
        } else {
            map.put("code", "-1");
            map.put("msg", "requestData is null");
        }
        return map;
    }


    /**
     * 放鑫钱包-进件接口
     *
     * @param param
     * @return
     */
    @Log(title = "放鑫钱包-进件接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByFangXinQianBao", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByFangXinQianBao(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "放鑫钱包";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("requestData"))) {
            String requestData = FangXinQianBaoAESUtils.decrypt(FangXinQianBaoAESUtils.KEY,
                    FangXinQianBaoAESUtils.KEY, param.getString("requestData"));
            JSONObject jsonObject = JSONObject.parseObject(requestData);
            Customer customer = new Customer();
            customer.setLaiyuan(laiyuan);

            Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                customer.setCusName(v);
            });
            Optional.ofNullable(jsonObject.getInteger("sex")).ifPresent(v -> {
                customer.setSex(v == 1 ? "男" : "女");
            });
            Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(v -> {
                customer.setPhone(v);
            });
            Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                customer.setAge(v);
            });
            Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                customer.setCityName(v);

            });

            // 宁波推送-放鑫钱包
//            if (customer.getCityName().contains("宁波")) {
//                Map nbMap = new HashMap();
//                JSONObject jsonNb = NingBoPushCustomer(Ning_Bo_URL + "/insertCustomerByFangXinQianBao", param);
//                if ("1".equals(jsonNb.get("code"))) {
//                    nbMap.put("code", 1);
//                    nbMap.put("data", null);
//                    nbMap.put("msg", "成功");
//                } else {
//                    nbMap.put("code", -1);
//                    nbMap.put("data", null);
//                    nbMap.put("msg", "失败");
//                }
//                return nbMap;
//            }
            Optional.ofNullable(jsonObject.getString("profession")).ifPresent(v -> {
                String works = "";
                switch (v) {
                    case "1":
                        works = "上班族";
                        break;
                    case "3":
                        works = "自由职业";
                        break;
                    case "2":
                        works = "公务员";
                        break;
                    default:
                        works = "其他";
                }
                customer.setWorks(works);
            });
            Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                String houseType = "";
                switch (v) {
                    case 1:
                        houseType = "有房可抵押";
                        break;
                    case 2:
                        houseType = "有房不抵押";
                        break;
                    case 3:
                        houseType = "无房产";
                        break;

                }
                customer.setHouseType(houseType);
            });
            Optional.ofNullable(jsonObject.getString("vehicle")).ifPresent(v -> {
                String carStatus = "";
                switch (v) {
                    case "1":
                        carStatus = "有车可抵押";
                        break;
                    case "2":
                        carStatus = "有车不抵押";
                        break;
                    case "3":
                        carStatus = "无车产";
                        break;

                }
                customer.setCarStatus(carStatus);
            });
            Optional.ofNullable(jsonObject.getInteger("sesame")).ifPresent(v -> {
                customer.setSesameScore(v + "");
            });

            Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(v -> {
                customer.setAmount(v);
            });
            Optional.ofNullable(jsonObject.getString("loanPurpose")).ifPresent(v -> {
                String use = "";
                switch (v) {
                    case "1":
                        use = "装修贷款";
                        break;
                    case "2":
                        use = "日常消费";
                        break;
                    case "3":
                        use = " 旅游贷款";
                        break;
                    case "4":
                        use = "医疗贷款";
                        break;
                    case "5":
                        use = "买车贷款";
                        break;
                    case "6":
                        use = "其他";
                        break;
                }
                customer.setLoanUse(use);
            });
            Optional.ofNullable(jsonObject.getString("socialSecurity")).ifPresent(v -> {
                String social = "";
                switch (v) {
                    case "1":
                        social = "连续缴纳 6 个月及以上";
                        break;
                    case "2":
                        social = "缴纳未满 6 个月";
                        break;
                    case "3":
                        social = "无社保";
                        break;
                }
                customer.setSocial(social);
            });
            Optional.ofNullable(jsonObject.getString("businessInsurance")).ifPresent(v -> {
                String baodan = "";
                switch (v) {
                    case "1":
                        baodan = "连续缴纳一年及以上";
                        break;
                    case "2":
                        baodan = "缴纳未满一年";
                        break;
                    case "3":
                        baodan = "无保单";
                        break;
                }
                customer.setBaodanScop(baodan);
            });
            Optional.ofNullable(jsonObject.getString("monthIncome")).ifPresent(v -> {
                String income = "";
                switch (v) {
                    case "1":
                        income = "5 千以下";
                        break;
                    case "2":
                        income = "5 千-1 万";
                        break;
                    case "3":
                        income = "1 万-1.5 万";
                        break;
                    case "4":
                        income = "1.5 万-3 万";
                        break;
                    case "5":
                        income = "3 万以上";
                        break;

                }
                customer.setIncomeMonth(income);
            });
            Optional.ofNullable(jsonObject.getString("businessOwners")).ifPresent(v -> {
                String businessOwners = "";
                switch (v) {
                    case "1":
                        businessOwners = "有营业执照";
                        break;
                    case "2":
                        businessOwners = "无营业执照";
                        break;
                }
                customer.setHasBusinessLicense(businessOwners);
            });
            Optional.ofNullable(jsonObject.getString("accumulationFund")).ifPresent(v -> {
                String accumulationFund = "";
                switch (v) {
                    case "1":
                        accumulationFund = "连续缴纳6个月及以上";
                        break;
                    case "2":
                        accumulationFund = "缴纳未满6个月";
                        break;
                    case "3":
                        accumulationFund = "无公积金";
                        break;
                }
                customer.setAccumulation(accumulationFund);
            });
            Optional.ofNullable(jsonObject.getString("batitaoQuota")).ifPresent(v -> {
                customer.setRemark(v);
            });
            Optional.ofNullable(jsonObject.getString("mark")).ifPresent(v -> {
                customer.setRemark(customer.getRemark() + "/" + v);
            });

            Map resMap = customerService.savePushCustomer(customer);
            if ("200".equals(resMap.get("code"))) {
                map.put("code", 1);
                map.put("data", null);
                map.put("msg", "成功");
            } else {
                map.put("code", -1);
                map.put("data", null);
                map.put("msg", "失败");
            }

            return map;
        } else {
            map.put("code", "-1");
            map.put("msg", "requestData is null");
        }
        return map;
    }


    /**
     * 趣享花
     *
     * @param param
     * @return
     */
    @Log(title = "趣享花-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByQuXiangHuaIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByQuXiangHuaIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "趣享花";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("timestamp"))) {
            String requestData = QuXiangHuaAesUtils.decrypt(param.getString("timestamp"), param.getString("signs"));
            if (StringUtils.isNotEmpty(requestData)) {
                JSONObject jsonObject = JSONObject.parseObject(requestData);
                String phone = jsonObject.getString("mobileMask");
                phone = phone.substring(0, 9);
                Customer customer = new Customer();
                customer.setPhone(phone);
                List<Customer> customers = customerService.findList(customer);
                List<String> list = new ArrayList<>();
                if (!customers.isEmpty()) {
                    for (Customer cus : customers) {
                        customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                        list.add(Md5Utils.hash(cus.getPhone()));
                    }
                }
//                list = NingBoIsCheckCustomerList(list, Ning_Bo_URL + "/insertCustomerByQuXiangHuaIsCheck", param,
//"md5List");
                JSONObject data = new JSONObject();
                JSONObject md5List = new JSONObject();
                md5List.put("md5List", list);
                data.put("timestamp", param.getString("timestamp"));
                data.put("signs", QuXiangHuaAesUtils.encrypt(param.getString("timestamp"), md5List.toJSONString()));
                map.put("result", "200");
                map.put("data", data);
                map.put("message", "success");
            } else {
                map.put("result", "1");
                map.put("message", "解密失败");
            }
            return map;
        } else {
            map.put("result", "1");
            map.put("message", "timestamp is null");
        }
        return map;
    }


    /**
     * 趣享花-进件接口
     *
     * @param param
     * @return
     */
    @Log(title = "趣享花-进件接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByQuXiangHua", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByQuXiangHua(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "趣享花";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("timestamp"))) {
            String requestData = QuXiangHuaAesUtils.decrypt(param.getString("timestamp"), param.getString("signs"));
            if (StringUtils.isNotEmpty(requestData)) {
                JSONObject jsonObject = JSONObject.parseObject(requestData);
                Customer customer = new Customer();
                customer.setLaiyuan(laiyuan);
                Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getString("userName")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                // 宁波推送-趣享花
//                if (customer.getCityName().contains("宁波")) {
//                    Map nbMap = new HashMap();
//                    JSONObject jsonNb = NingBoPushCustomer(Ning_Bo_URL + "/insertAesCustomer", param);
//                    if ("200".equals(jsonNb.get("code"))) {
//                        nbMap.put("code", 200);
//                        map.put("data", new HashMap<>());
//                        nbMap.put("message", "成功");
//                    } else {
//                        nbMap.put("code", 500);
//                        map.put("data", new HashMap<>());
//                        nbMap.put("message", jsonNb.get("message"));
//                    }
//                    return nbMap;
//                }

                Optional.ofNullable(jsonObject.getInteger("sex")).ifPresent(v -> {
                    customer.setSex(v == 1 ? "男" : "女");
                });

                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getString("applyLimit")).ifPresent(v -> {
                    customer.setAmount(v);
                });


                Optional.ofNullable(jsonObject.getInteger("hasHouse")).ifPresent(v -> {
                    String houseType = "";
                    switch (v) {
                        case 1:
                            houseType = "有房";
                            break;
                        case 0:
                            houseType = "无房产";
                            break;

                    }
                    customer.setHouseType(houseType);
                });
                Optional.ofNullable(jsonObject.getString("hasCar")).ifPresent(v -> {
                    String carStatus = "";
                    switch (v) {
                        case "1":
                            carStatus = "有车";
                            break;
                        case "0":
                            carStatus = "无车";
                            break;

                    }
                    customer.setCarStatus(carStatus);
                });
                Optional.ofNullable(jsonObject.getString("hasFund")).ifPresent(v -> {
                    String accumulation = "";
                    switch (v) {
                        case "1":
                            accumulation = "有公积金";
                            break;
                        case "0":
                            accumulation = "无公积金";
                            break;

                    }
                    customer.setAccumulation(accumulation);
                });
                Optional.ofNullable(jsonObject.getString("hasSocial")).ifPresent(v -> {
                    String hasSocial = "";
                    switch (v) {
                        case "1":
                            hasSocial = "有社保";
                            break;
                        case "0":
                            hasSocial = "无社保";
                            break;

                    }
                    customer.setSocial(hasSocial);
                });
                Optional.ofNullable(jsonObject.getString("hasPolicy")).ifPresent(v -> {
                    String hasPolicy = "";
                    switch (v) {
                        case "1":
                            hasPolicy = "有保单";
                            break;
                        case "0":
                            hasPolicy = "无保单";
                            break;

                    }
                    customer.setPolicy(hasPolicy);
                });
                Optional.ofNullable(jsonObject.getString("hasCredit")).ifPresent(v -> {
                    String hasCredit = "";
                    switch (v) {
                        case "1":
                            hasCredit = "有信用卡";
                            break;
                        case "0":
                            hasCredit = "无信用卡";
                            break;

                    }
                    customer.setCreditCard(hasCredit);
                });
                Optional.ofNullable(jsonObject.getString("system")).ifPresent(v -> {
                    customer.setBrand(v);
                });

                Optional.ofNullable(jsonObject.getString("appId")).ifPresent(v -> {
                    customer.setRemark(v);
                });
                Optional.ofNullable(jsonObject.getString("appKey")).ifPresent(v -> {
                    customer.setRemark(customer.getRemark() + "/" + v);
                });
                Map resMap = customerService.savePushCustomer(customer);
                if ("200".equals(resMap.get("code"))) {
                    map.put("code", "200");
                    map.put("data", new HashMap<>());
                    map.put("message", "成功");
                } else {
                    map.put("code", 1);
                    map.put("message", map.get("message"));
                }
                return map;
            } else {
                map.put("result", "1");
                map.put("message", "解密失败");
            }
        } else {
            map.put("code", "1");
            map.put("msg", "timestamp is null");
        }
        return map;
    }

    /**
     * 云象优客
     *
     * @param param
     * @return
     */
    @Log(title = "云象优客-撞库接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByYunXiangYouKeIsCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByYunXiangYouKeIsCheck(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "云象优客";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("appId")) && StringUtils.isNotEmpty(param.getString("appKey")) && YunXiangYouKeAESUtils.APPID.equals(param.getString("appId")) && YunXiangYouKeAESUtils.APPKEY.equals(param.getString("appKey"))) {
            String requestData = YunXiangYouKeAESUtils.decrypt(YunXiangYouKeAESUtils.KEY, YunXiangYouKeAESUtils.IV,
                    param.getString("mobileAES"));
            if (StringUtils.isNotEmpty(requestData)) {
                String phone = requestData;
                Customer customer = new Customer();
                customer.setPhone(phone);
                List<Customer> customers = customerService.findList(customer);
                List<String> list = new ArrayList<>();
                for (Customer cus : customers) {
                    customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                    list.add(Md5Utils.hash(cus.getPhone()));
                }
                if (customers.size() > 0) {
                    map.put("code", "000000");
                    map.put("mobileMd5List", list);
                    map.put("msg", "手机号已存在");
                } else {
                    map.put("code", "000000");
                    map.put("mobileMd5List", list);
                    map.put("msg", "可以接受");
                }
            } else {
                map.put("code", "999999");
                map.put("msg", "解密失败");
            }
            return map;
        } else {
            map.put("code", "999999");
            map.put("msg", "appId is null or error");
        }
        return map;
    }


    /**
     * 云象优客-进件接口
     *
     * @param param
     * @return
     */
    @Log(title = "云象优客-进件接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByYunXiangYouKe", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByYunXiangYouKe(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "云象优客";
        Map map = new HashMap();
        if (StringUtils.isNotEmpty(param.getString("sign")) && Md5Utils.hash(YunXiangYouKeAESUtils.APPID + YunXiangYouKeAESUtils.APPKEY + param.getString("consumeTime")).equals(param.getString("sign"))) {
            String requestData = YunXiangYouKeAESUtils.decrypt(YunXiangYouKeAESUtils.KEY, YunXiangYouKeAESUtils.IV,
param.getString("data"));
            if (StringUtils.isNotEmpty(requestData)) {
                JSONObject jsonObject = JSONObject.parseObject(requestData);
                Customer customer = new Customer();
                customer.setLaiyuan(laiyuan);
                Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(v -> {
                    customer.setPhone(v);
                });
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(v -> {
                    customer.setCusName(v);
                });
                Optional.ofNullable(jsonObject.getString("workCity")).ifPresent(v -> {
                    customer.setCityName(v);
                });
                Optional.ofNullable(jsonObject.getString("sex")).ifPresent(v -> {
                    customer.setSex(v.equals("MALE") ? "男" : "女");
                });

                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(v -> {
                    customer.setAge(v);
                });
                Optional.ofNullable(jsonObject.getInteger("amount")).ifPresent(v -> {
                    customer.setAmount(v + "");
                });

                Optional.ofNullable(jsonObject.getString("incomeType")).ifPresent(v -> {
                    String incomeType = "";
                    switch (v) {
                        case "BANK":
                            incomeType = "银行代发";
                            break;
                        case "CASH":
                            incomeType = "现金发放";
                            break;
                    }
                    customer.setPayoffType(incomeType);
                });


                Optional.ofNullable(jsonObject.getString("house")).ifPresent(v -> {
                    String houseType = "";

                    switch (v) {
                        case "NO_HOUSE":
                            houseType = "无房";
                            break;
                        case "HAS_HOUSE":
                            houseType = "有房";
                            break;
                        case "HAS_HOUSE_MORTGAGE":
                            houseType = "有且接收抵押";
                            break;

                    }
                    customer.setHouseType(houseType);
                });
                Optional.ofNullable(jsonObject.getString("car")).ifPresent(v -> {
                    String carStatus = "";
                    switch (v) {
                        case "NO_CAR":
                            carStatus = "无车";
                            break;
                        case "HAS_CAR":
                            carStatus = "有车";
                            break;
                        case "HAS_CAR_MORTGAGE":
                            carStatus = "有且接收抵押";
                            break;

                    }
                    customer.setCarStatus(carStatus);
                });
                Optional.ofNullable(jsonObject.getString("accumulationFund")).ifPresent(v -> {
                    String accumulation = "";
                    switch (v) {
                        case "KEEP_SIX":
                            accumulation = "6个月以上";
                            break;
                        case "UNDER_SIX":
                            accumulation = "6个月以下";
                            break;
                        case "NO":
                            accumulation = "无社保";
                            break;

                    }
                    customer.setAccumulation(accumulation);
                });
                Optional.ofNullable(jsonObject.getString("social")).ifPresent(v -> {

                    String hasSocial = "";
                    switch (v) {
                        case "KEEP_SIX":
                            hasSocial = "6个月以上";
                            break;
                        case "UNDER_SIX":
                            hasSocial = "6个月以下";
                            break;
                        case "NO":
                            hasSocial = "无社保";
                            break;

                    }
                    customer.setSocial(hasSocial);
                });
                Optional.ofNullable(jsonObject.getString("insurance")).ifPresent(v -> {
                    String hasPolicy = "";
                    switch (v) {
                        case "LESS_THAN_TWO_YEARS":
                            hasPolicy = "投保人寿险且投保两年以下";
                            break;
                        case "NO_INSURANCE":
                            hasPolicy = "无保单";
                            break;
                        case "MORE_THAN_TWO_YEARS":
                            hasPolicy = "投保人寿险且投 保两年以上";
                            break;

                    }
                    customer.setPolicy(hasPolicy);
                });

                Optional.ofNullable(jsonObject.getString("source")).ifPresent(v -> {
                    customer.setBrand(v);
                });

                Optional.ofNullable(jsonObject.getString("productName")).ifPresent(v -> {
                    customer.setRemark(v);
                });
                Optional.ofNullable(jsonObject.getString("orgOpenId")).ifPresent(v -> {
                    customer.setApiSourceName(v);
                });
                Optional.ofNullable(jsonObject.getString("orderBizNo")).ifPresent(v -> {
                    customer.setClueId(v);
                });
                Map resMap = customerService.savePushCustomer(customer);
                if ("200".equals(resMap.get("code"))) {
                    map.put("code", "000000");
                    map.put("msg", "消耗成功");
                } else {
                    map.put("code", "999999");
                    map.put("msg", map.get("message"));
                }
            } else {
                map.put("code", "999999");
                map.put("msg", "解密失败");
            }
            return map;
        } else {
            map.put("code", "999999");
            map.put("msg", "验签错误");
        }

        return map;
    }


    public List<String> NingBoIsCheckCustomerList(List<String> list, String url, JSONObject param, String dataKey) {
        try {
            // 撞下宁波的撞库
            String res = HttpUtils.doPost(url, param);
            JSONObject jsonObject = JSONObject.parseObject(res);
            if (StringUtils.isNotNull(jsonObject.getInteger("code")) && 200 == jsonObject.getInteger("code")) {
                JSONArray customerJsonList = jsonObject.getJSONArray(dataKey);
                for (Object o : customerJsonList) {
                    list.add((String) o);
                }
            }
        } catch (Exception e) {
            logger.error("=====撞下宁波的撞库======", e);
        }
        return list;
    }


    /**
     * 锦鱼API推送
     *
     * @param param
     * @return
     */
    @Log(title = "锦鱼-推送接口", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertCustomerByJingYuPush", method = RequestMethod.POST)
    @ResponseBody
    public Map insertCustomerByJingYuPush(@RequestBody JSONObject param) throws Exception {
        String laiyuan = "锦鱼";
        Map map = new HashMap();
        if (AesByJinYuUtils.channelCode.equals(param.getString("channelCode"))) {
            JSONObject jsonObject = JSON.parseObject(AesByJinYuUtils.decrypt(param.getString("data")));
            if (jsonObject != null) {
                Customer customer = new Customer();
                customer.setLaiyuan(laiyuan);
                Optional.ofNullable(jsonObject.getString("mobile")).ifPresent(customer::setPhone);
                Optional.ofNullable(jsonObject.getString("customerName")).ifPresent(customer::setCusName);
                Optional.ofNullable(jsonObject.getString("idCard")).ifPresent(customer::setIdCard);
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(customer::setAge);
                Optional.ofNullable(jsonObject.getInteger("gender")).ifPresent(v -> {
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "男";
                            break;
                        case 2:
                            content = "女";
                            break;
                    }
                    customer.setSex(content);

                });
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(customer::setCityName);
                Optional.ofNullable(jsonObject.getInteger("occupation")).ifPresent(v -> {

                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "自由职业";
                            break;
                        case 2:
                            content = "上班族";
                            break;
                        case 3:
                            content = "企业主/个体户";
                            break;
                        case 4:
                            content = "公务员/事业/国企";
                            break;

                    }
                    customer.setWorks(content);
                });
                Optional.ofNullable(jsonObject.getInteger("credit")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "一年内有逾期";
                            break;
                        case 2:
                            content = "一年内无逾期";
                            break;
                        case 3:
                            content = "从未逾期";
                            break;

                    }
                    customer.setZx(content);


                });

                Optional.ofNullable(jsonObject.getInteger("loans")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "3次以上";
                            break;
                        case 2:
                            content = "3次及以内";
                            break;
                        case 3:
                            content = "无申请贷款";
                            break;

                    }
                    customer.setRemark(content);
                });

                Optional.ofNullable(jsonObject.getInteger("sesameLevel")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "600分及以下";
                            break;
                        case 3:
                            content = "600-650分";
                            break;
                        case 4:
                            content = "650-700分";
                            break;
                        case 5:
                            content = "700以上";
                            break;

                    }
                    customer.setSesameScore(content);
                });

                Optional.ofNullable(jsonObject.getInteger("socialSecurity")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "600分及以下";
                            break;
                        case 3:
                            content = "600-650分";
                            break;
                        case 4:
                            content = "650-700分";
                            break;
                        case 5:
                            content = "700以上";
                            break;

                    }
                    customer.setSocial(content);
                });


                Optional.ofNullable(jsonObject.getInteger("fund")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;
                        case 3:
                            content = "未满6个月";
                            break;
                        case 4:
                            content = "满6个月及以上";
                            break;
                    }
                    customer.setAccumulation(content);
                });

                Optional.ofNullable(jsonObject.getInteger("house")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;

                    }
                    customer.setHouseType(content);
                });

                Optional.ofNullable(jsonObject.getInteger("car")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;
                        case 3:
                            content = "有车不可抵押";
                            break;
                        case 4:
                            content = "有车可抵押";
                            break;

                    }
                    customer.setCarModel(content);
                });

                Optional.ofNullable(jsonObject.getInteger("car")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;
                        case 3:
                            content = "缴纳未满1年";
                            break;
                        case 4:
                            content = "缴纳1年以上";
                            break;

                    }
                    customer.setPolicy(content);
                });

                Optional.ofNullable(jsonObject.getInteger("car")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;
                        case 3:
                            content = "1万元以下";
                            break;
                        case 4:
                            content = "1万元及以上";
                            break;

                    }
                    customer.setCreditCard(content);
                });

                Optional.ofNullable(jsonObject.getInteger("huabei")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;


                    }
                    customer.setRemark(customer.getRemark() + "/花呗：" + content);
                });

                Optional.ofNullable(jsonObject.getInteger("baitiao")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "无";
                            break;
                        case 2:
                            content = "有";
                            break;


                    }
                    customer.setRemark(customer.getRemark() + "/京东白条：" + content);
                });

                Optional.ofNullable(jsonObject.getInteger("requiredAmount")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "5万以下";
                            break;
                        case 2:
                            content = "5万-10万";
                            break;
                        case 3:
                            content = "10万-20万";
                            break;
                        case 4:
                            content = "20万以上";
                            break;

                    }
                    customer.setAmount(content);
                });

                Optional.ofNullable(jsonObject.getInteger("loanPurpose")).ifPresent(v -> {
                    /**
                     *  0:未知, 1:一年内有逾期, 2:一年内无逾期, 3:从未逾期
                     */
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "消费";
                            break;
                        case 2:
                            content = "房抵";
                            break;
                        case 3:
                            content = "车抵";
                            break;
                        case 4:
                            content = "经营";
                            break;

                    }
                    customer.setLoanUse(content);
                });
                Optional.ofNullable(jsonObject.getString("remarks")).ifPresent(v -> {
                    customer.setRemark(customer.getRemark() + "/" + v);
                });
                customerService.savePushCustomer(customer);
                map.put("code", "200");
                map.put("msg", "success");
            } else {
                map.put("code", "500");
                map.put("msg", "解密失败");
            }

        } else {
            map.put("code", "500");
            map.put("msg", "渠道码错误");
        }
        return map;
    }

    public JSONObject NingBoPushCustomer(String url, JSONObject param) {
        JSONObject resResult = new JSONObject();
        try {
            String res = HttpUtils.doPost(url, param);
            resResult = JSONObject.parseObject(res);
            if (StringUtils.isNotNull(resResult.getInteger("code")) && 200 == resResult.getInteger("code")) {
                return resResult;
            } else {
                return resResult;
            }
        } catch (Exception e) {
            logger.error("=====推送宁波的数据异常======", e);
        }
        return resResult;

    }

    @Log(title = "微融宝进件", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertWeiRongBaoAesCustomer", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> insertWeiRongBaoAesCustomer(@RequestBody JSONObject param) throws Exception {
        Map<String, Object> map = new HashMap<>();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            JSONObject jsonObject =
                                JSONObject.parseObject(Objects.requireNonNull(XunSuBangAesUtils.decrypt(param.getString("data"),
             "YJA5F60ff5N23Rsk")));
            if (StringUtils.isNotNull(jsonObject)) {
                Customer customer = new Customer();
                customer.setLaiyuan("微融宝");
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(customer::setPhone);
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(customer::setCusName);
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(customer::setCityName);
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(customer::setAge);
                Optional.ofNullable(jsonObject.getString("loanAmount")).ifPresent(customer::setAmount);
                Optional.ofNullable(jsonObject.getInteger("car")).ifPresent(v -> {
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "无车产";
                            break;
                        case 1:
                            content = "有车产，不抵押";
                            break;
                        case 2:
                            content = "有车产，可抵押";
                            break;
                    }
                    customer.setCarStatus(content);
                });

                Optional.ofNullable(jsonObject.getString("pgPrice")).ifPresent(customer::setPgPrice);
                Optional.ofNullable(jsonObject.getString("carNo")).ifPresent(customer::setCarNo);
                map = customerService.savePushCustomer(customer);
            }
        } else {
            map.put("message", "data 解密失败");
            map.put("code", "500");
        }
        return map;
    }


    /**
     * 加密撞库微融宝
     * 手机号码
     *
     * @param
     * @return
     */
    @Log(title = "加密撞库微融宝", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertWeiRongBaoCustomerAesCheck", method = RequestMethod.POST)
    @ResponseBody
    public Map<String, Object> insertWeiRongBaoCustomerAesCheck(@RequestBody JSONObject param) throws Exception {
        Map<String, Object> map = new HashMap<>();
        String laiyuan = param.getString("laiyuan");
        if (StringUtils.isNotNull(param.getString("data"))) {
            JSONObject jsonObject =
            JSONObject.parseObject(Objects.requireNonNull(XunSuBangAesUtils.decrypt(param.getString("data"),
"YJA5F60ff5N23Rsk")));
            String phone = jsonObject.getString("phoneMd5");
            if (StringUtils.isNotEmpty(phone)) {
                Customer customer = new Customer();
                customer.setPhoneMD5(phone);
                List<Customer> customers = customerService.findList(customer);
                if (!customers.isEmpty()) {
                    List<String> list = new ArrayList<>();
                    for (Customer cus : customers) {
                        customerService.updateStatusIfExistedAfterCheck(cus, laiyuan, phone, customers.size());
                        list.add(Md5Utils.hash(cus.getPhone()));
                    }

                    map.put("code", "500");
                    map.put("msg", "success");
                } else {
                    map.put("code", "200");
                    map.put("msg", "success");
                }
                Map<String, Object> data = new HashMap<>();
                String companyName = ConfigUtils.getConfigByKeyNoCache("weirongbao.companyName").getConfigValue();
                String protocolList = ConfigUtils.getConfigByKeyNoCache("weirongbao.protocolList").getConfigValue();
                String logo = ConfigUtils.getConfigByKeyNoCache("weirongbao.company.logo").getConfigValue();
                data.put("price", null);
                data.put("companyName", companyName);
                data.put("productName", null);
                data.put("logo", logo);
                List<WeiRongBackBo> weiRongBackBos = new ArrayList<>();
                weiRongBackBos.add(new WeiRongBackBo("个人信息共享授权书", protocolList));
                data.put("protocolList", weiRongBackBos);
                map.put("data", data);

            } else {
                map.put("msg", "mobile is null or laiyuan is null or bytes is null ");
                map.put("code", -1);
            }
        }


        return map;
    }

    /**
     * 海通-客户进件
     * 手机号码
     *
     * @param
     * @return
     */
    @Log(title = "海通-客户进件", businessType = BusinessType.INSERT)
    @RequestMapping(value = "/insertHaiTongCustomer", method = RequestMethod.POST)
    @ResponseBody
    public String insertHaiTongCustomer(@RequestBody JSONObject param) throws Exception {
        Map<String, Object> map = new HashMap<>();
        if (StringUtils.isNotEmpty(param.getString("data"))) {
            JSONObject jsonObject = JSONObject.parseObject(Objects.requireNonNull(AESUtils.Decrypt(param.getString(
                    "data"), "UmhX3f2Ej6I9kq15")));
            if (StringUtils.isNotNull(jsonObject)) {
                Customer customer = new Customer();
                customer.setLaiyuan("海通");
                Optional.ofNullable(jsonObject.getString("phone")).ifPresent(customer::setPhone);
                Optional.ofNullable(jsonObject.getString("name")).ifPresent(customer::setCusName);
                Optional.ofNullable(jsonObject.getString("city")).ifPresent(customer::setCityName);
                Optional.ofNullable(jsonObject.getInteger("age")).ifPresent(customer::setAge);
                Optional.ofNullable(jsonObject.getInteger("gender")).ifPresent(v -> {
                    String content = "";
                    switch (v) {
                        case 0:
                            content = "未知";
                            break;
                        case 1:
                            content = "男";
                            break;
                        case 2:
                            content = "女";
                            break;
                    }
                    customer.setSex(content);
                });

                Optional.ofNullable(jsonObject.getString("car_value")).ifPresent(customer::setCarNo);
                Optional.ofNullable(jsonObject.getString("id")).ifPresent(customer::setClueId);
                customerService.savePushCustomer(customer);
            }
        } else {
            return "fail";
        }

        return "success";
    }

}
